    // 插件对象实例，初始化为null，需要创建多个插件窗口时，需要定义多个插件对象实例变量，各个变量唯一标志对应的插件实例
    var oWebControl = null;
    var bIE = (!!window.ActiveXObject || 'ActiveXObject' in window);// 是否为IE浏览器
    var pubKey = '';                    // demo中未使用加密，可根据需求参照开发指南自行使用加密功能
	var initCount = 0;
    var playMode = 0;                   // 播放类型，0-预览，1-回放
	var showDivInstruction = false;     // 标志是否显示使用说明弹框
    
    var endTime = Math.floor(new Date(dateFormat(new Date(), "yyyy-MM-dd 23:59:59").replace('-', '/').replace('-', '/')).getTime() / 1000).toString();
    var startTime = Math.floor(new Date(dateFormat(new Date(), "yyyy-MM-dd 00:00:00").replace('-', '/').replace('-', '/')).getTime() / 1000).toString();
	var playTime = Math.floor(new Date(dateFormat(new Date(), "yyyy-MM-dd 00:00:00").replace('-', '/').replace('-', '/')).getTime() / 1000).toString();

    
    function UpdateInitParamValue(){
        var sel = document.getElementById("initFuncType");
        var selectedId = sel.selectedIndex;
        var v = sel.options[selectedId].value;
        var param;
        if (0 == v){                //更新为初始化请求的参数
            var result = JSON.stringify({
                "argument": {
                    "appkey": "",
                    "ip": "",
                    "port": 443,
                    "secret": "",
                    "enableHTTPS": 1,
                    "language": "zh_CN",
                    "layout": "2x2",
                    "playMode": 0,
                    "reconnectDuration": 5,
                    "reconnectTimes": 5,
                    "showSmart": 0,
                    "showToolbar": 1,
                    "toolBarButtonIDs": "2048,2049,2050,2304,2306,2305,2307,2308,2309,4096,4608,4097,4099,4098,4609,4100",
                    "snapDir": "D:/snap",
                    "videoDir": "D:/video"
                },
                "funcName": "init"
            }, null, 2);//将json对象转换成字符串
            //document.getElementById('initParam').innerText= result ;
            $("#initParam").val(result);
        }
        else if (1 == v)                //更新为反初始化请求的参数
        {
            var result = JSON.stringify({
                "funcName": "uninit"
            }, null, 2);//将json对象转换成字符串
            
            //document.getElementById('initParam').innerText= result ;
            $("#initParam").val(result);
        }
        else                            //更新为设置认证信息请求的参数
        {
            var result = JSON.stringify({
                "argument": {
                    "list": [
                        {
                            "appkey": "",
                            "authUuid": "111",
                            "ip": "",
                            "port": 443,
                            "secret": ""
                        },
                        {
                            "appkey": "",
                            "authUuid": "222",
                            "ip": "",
                            "port": 443,
                            "secret": ""
                        }
                    ]
                },
                "funcName": "setAuthInfo"
            }, null, 2);//将json对象转换成字符串
            //document.getElementById('initParam').innerText= result;
            $("#initParam").val(result);
        }
    }

    // 播放相关参数：
    var bofangData ;
    
    function UpdatePlayParamValue(data){
        // var sel = document.getElementById("playFuncType");
        // var selectedId = sel.selectedIndex;
        // var v = sel.options[selectedId].value;
        console.log(data,'data')
        const splData = data?.map((item,index)=>{
            return {
                "authUuid": "",
                "cameraIndexCode": item.cameraIndexCode || "",
                "ezvizDirect": 0,
                "gpuMode": 0,
                "streamMode": 0,
                "transMode": 1,
                "wndId": index+1
            }
        })
        var v = 1;
        var param;
        if (0 == v){                    //更新为单个播放请求的参数，根据初始化时的playmode字段，设置为预览或回放
            var result = 0 == playMode ? JSON.stringify({
                "argument": {
                  "authUuid": "",
                  "cameraIndexCode": "51060300021321723008",
                  "ezvizDirect": 0,
                  "gpuMode": 0,
                  "streamMode": 0,
                  "transMode": 1,
                  "wndId": -1,
                  "cascade": 1
                },
                "funcName": "startPreview"
              }, null, 2) : JSON.stringify({
                "argument": {
                    "authUuid": "",
                    "cameraIndexCode": "",
                    "endTimeStamp": endTime,
                    "ezvizDirect": 0,
                    "gpuMode": 0,
                    "playTimeStamp": startTime,
                    "recordLocation": 0,
                    "startTimeStamp": startTime,
                    "transMode": 1,
                    "wndId": 0,
		            "cascade": 1
                },
                "funcName": "startPlayback"
            }, null, 2);//将json对象转换成字符串
            //document.getElementById('playParam').innerText= result;
            // $("#playParam").val(result);
            bofangData=result
        }
        else if (1 == v)                    //更新为批量播放请求的参数，根据初始化时的playmode字段，设置为预览或回放
        {
            var result =  0 == playMode ? JSON.stringify({
                "argument": {
                    "list": splData
                },
                "funcName": "startMultiPreviewByCameraIndexCode"
            }, null, 2) : JSON.stringify({
                "argument": {
                    "list": [
                        {
                            "authUuid": "",
                            "cameraIndexCode": "",
                            "endTimeStamp": endTime,
                            "ezvizDirect": 0,
                            "gpuMode": 0,
                            "playTimeStamp": startTime,
                            "recordLocation": 0,
                            "startTimeStamp": startTime,
                            "transMode": 1,
                            "wndId": 1
                        },
                        {
                            "authUuid": "",
                            "cameraIndexCode": "",
                            "endTimeStamp": endTime,
                            "ezvizDirect": 0,
                            "gpuMode": 0,
                            "playTimeStamp": startTime,
                            "recordLocation": 0,
                            "startTimeStamp": startTime,
                            "transMode": 1,
                            "wndId": 2
                        }
                    ]
                },
                "funcName": "startMultiPlaybackByCameraIndexCode"
            }, null, 2);//将json对象转换成字符串
            //document.getElementById('playParam').innerText= result;
            // $("#playParam").val(result);
            bofangData=result
            console.log(bofangData,'`````')
        }
        else if (2 == v)                    //更新为批量停止播放请求的参数
        {
            var result = JSON.stringify({
                "argument": {
                    "list": [
                        {
                            "wndId": 1
                        },
                        {
                            "wndId": 2
                        }
                    ]
                },
                "funcName": "stopMultiPlay"
            }, null, 2);//将json对象转换成字符串
            //document.getElementById('playParam').innerText= result;
            // $("#playParam").val(result);
            bofangData=result
        }
        else                    //更新为停止所有播放请求的参数，根据初始化时的playmode字段，设置为预览或回放
        {
            var result =  0 == playMode ? JSON.stringify({
                "funcName": "stopAllPreview"
            }, null, 2) : JSON.stringify({
                "funcName": "stopAllPlayback"
            }, null, 2);//将json对象转换成字符串
            //document.getElementById('playParam').innerText= result;
            // $("#playParam").val(result);
            bofangData=result
        }
        console.log(bofangData,'bofangData')
        setTimeout(()=>{
            requestInterface(bofangData)
        },5000)
    }
    
    function UpdateLayoutParamValue(){
        var sel = document.getElementById("layoutFuncType");
        var selectedId = sel.selectedIndex;
        var v = sel.options[selectedId].value;
        var param;
        if (0 == v){                    //更新为获取布局请求的参数
            var result = JSON.stringify({
                "funcName": "getLayout"
            }, null, 2);//将json对象转换成字符串
            //document.getElementById('layoutParam').innerText= result;
            $("#layoutParam").val(result);
        }
        else                    //更新为设置布局请求的参数
        {
            var result = JSON.stringify({
                "argument": {
                    "layout": "2x2"
                },
                "funcName": "setLayout"
            }, null, 2);//将json对象转换成字符串
            //document.getElementById('layoutParam').innerText= result;
            $("#layoutParam").val(result);
        }
    }

    // 切换页面的时候
    function undataHtml(){
        if (oWebControl != null){
            oWebControl.JS_HideWnd();  // 先让窗口隐藏，规避可能的插件窗口滞后于浏览器消失问题
            // oWebControl.JS_Disconnect().then(function(){}, function() {});
        }
    }

    // 打开摄像头插件
    function openDataHtml(){
        if (oWebControl != null){
            oWebControl.JS_ShowWnd();
        }
    }
    
    // 标签关闭
    $(window).unload(function () {	
        undataHtml()
    });

    // 窗口resize
    $(window).resize(function () {
        if (oWebControl != null) {
            // oWebControl.JS_Resize("100%", "100%");
            // setWndCover();
        }
    });

    // 滚动条scroll
    $(window).scroll(function () {
        if (oWebControl != null) {
            // oWebControl.JS_Resize(800, 400);
            // setWndCover();
        }
    });

    // 设置窗口裁剪，当因滚动条滚动导致窗口需要被遮住的情况下需要JS_CuttingPartWindow部分窗口
    function setWndCover() {
        //获取web页面的尺寸
        var iWidth = $(window).width();
        var iHeight = $(window).height();
        //获取播放窗口div元素的左边界、右边界距离web页面左边界的长度、上边界、下边界距离web页面上边界的长度
        var oDivRect = $("#playWnd").get(0).getBoundingClientRect();
        //Math.round 为四舍五入    Math.abs 为取绝对值
        var iCoverLeft = (oDivRect.left < 0) ? Math.abs(oDivRect.left): 0;
        var iCoverTop = (oDivRect.top < 0) ? Math.abs(oDivRect.top): 0;
        var iCoverRight = (oDivRect.right - iWidth > 0) ? Math.round(oDivRect.right - iWidth) : 0;
        var iCoverBottom = (oDivRect.bottom - iHeight > 0) ? Math.round(oDivRect.bottom - iHeight) : 0;

        iCoverLeft = (iCoverLeft > 800) ? 800 : iCoverLeft;
        iCoverTop = (iCoverTop > 400) ? 400 : iCoverTop;
        iCoverRight = (iCoverRight > 800) ? 800 : iCoverRight;
        iCoverBottom = (iCoverBottom > 400) ? 400 : iCoverBottom;

		oWebControl.JS_RepairPartWindow(0, 0, 801, 400);  // 多1个像素点防止还原后边界缺失一个像素条
        //抠除左边界
        if (iCoverLeft != 0) {
			oWebControl.JS_CuttingPartWindow(0, 0, iCoverLeft, 401);
        }
        //抠除上边界
        if (iCoverTop != 0) {
            oWebControl.JS_CuttingPartWindow(0, 0, 801, iCoverTop);  // 多剪掉一个像素条，防止出现剪掉一部分窗口后出现一个像素条
        }
        //抠除右边界
        if (iCoverRight != 0) {
            oWebControl.JS_CuttingPartWindow(801 - iCoverRight, 0, iCoverRight, 401);
        }
        //抠除下边界
        if (iCoverBottom != 0) {
            oWebControl.JS_CuttingPartWindow(0, 401 - iCoverBottom, 801, iCoverBottom);
        }
        //弹框示例位置扣除
        if (showDivInstruction)
        {
            // 获取弹框的位置、尺寸信息
            var oDivLightRect = document.getElementById('light').getBoundingClientRect();
            
            iCoverLeft = (oDivLightRect.left - oDivRect.left < 0) ? 0 : oDivLightRect.left - oDivRect.left;
            iCoverTop = (oDivLightRect.top - oDivRect.top < 0) ? 0 : oDivLightRect.top - oDivRect.top;
            iCoverRight = (oDivLightRect.right - oDivRect.left < 0) ? 0 : oDivLightRect.right - oDivRect.left;
            iCoverBottom = (oDivLightRect.bottom - oDivRect.top < 0) ? 0 : oDivLightRect.bottom - oDivRect.top;
            
            iCoverLeft = (iCoverLeft > 800) ? 800 : Math.round(iCoverLeft);
            iCoverTop = (iCoverTop > 400) ? 400 : Math.round(iCoverTop);
            iCoverRight = (iCoverRight > 800) ? 800 : Math.round(iCoverRight);
            iCoverBottom = (iCoverBottom > 400) ? 400 : Math.round(iCoverBottom);

            //JS_CuttingPartWindow接口参照开发指南，参数为：抠图左上角点在插件窗口上的left长度、top长度、所扣除矩形区域的宽度、所扣除矩形区域的长度
            oWebControl.JS_CuttingPartWindow(iCoverLeft - 1, iCoverTop - 1, iCoverRight - iCoverLeft + 2, iCoverBottom - iCoverTop + 2);
        }
    }
	
    // 获取窗口信息
function getWndInfo() {
    return $("#playWnd").get(0).getBoundingClientRect();
  }

  
// 创建插件实例，并启动本地服务建立websocket连接，创建插件窗口
function initPlugin() {
    return new Promise((resolve, reject) => {
      oWebControl = new WebControl({
        szPluginContainer: "playWnd",
        iServicePortStart: 15900,
        iServicePortEnd: 15900,
        szClassId: "23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // 用于IE10使用ActiveX的clsid
        cbConnectSuccess: function() {
          initCount = 0;
        //   setCallbacks();
          oWebControl.JS_StartService("window", {dllPath: "./VideoPluginConnect.dll"}).then(function() {
            oWebControl.JS_CreateWnd("playWnd", getWndInfo().width, getWndInfo().height).then(function() {
              console.log("JS_CreateWnd success");
              oWebControl.JS_RequestInterface({
                funcName: "getRSAPubKey",
                argument: JSON.stringify({keyLength: 1024})
              }).then(function(oData) {
                resolve('aaaaaaaaaaaaaa')
                console.log('2222222222223333333333333333333333333')
                console.log(oData)
                if (oData.responseMsg.data) {
                  pubKey = oData.responseMsg.data
                }
              });
            });
          }, function() {
  
          });
        },
        cbConnectError: function() {
          console.log("cbConnectError");
          oWebControl = null;
          $("#playWnd").html("插件未启动，正在尝试启动，请稍候...");
          WebControl.JS_WakeUp("VideoWebPlugin://");
          initCount++;
          if (initCount < 3) {
            setTimeout(function() {
              initPlugin();
            }, 3000)
          } else {
            $("#playWnd").html("插件启动失败，请检查插件是否安装！");
          }
        },
        cbConnectClose: function(bNormalClose) {
          // 异常断开：bNormalClose = false
          // JS_Disconnect正常断开：bNormalClose = true
          console.log("cbConnectClose");
          oWebControl = null;
          $("#playWnd").html("插件未启动，正在尝试启动，请稍候...");
          WebControl.JS_WakeUp("VideoWebPlugin://");
          initCount++;
          if (initCount < 3) {
            setTimeout(function() {
              initPlugin();
            }, 3000)
          } else {
            $("#playWnd").html("插件启动失败，请检查插件是否安装！");
          }
        }
      });
  
    })
  
  
  
  }
	
	

    // 获取公钥
    function getPubKey (callback) {
        oWebControl.JS_RequestInterface({
            funcName: "getRSAPubKey",
            argument: JSON.stringify({
                keyLength: 1024
            })
        }).then(function (oData) {
            console.log(oData)
            if (oData.responseMsg.data) {
                pubKey = oData.responseMsg.data
                callback()
            }
        })
    }

    // 设置窗口控制回调
    function setCallbacks() {
        oWebControl.JS_SetWindowControlCallback({
            cbIntegrationCallBack: cbIntegrationCallBack
        });
    }

      // 推送消息
      function cbIntegrationCallBack(oData) {
        // showCBInfo(JSON.stringify(oData.responseMsg));
    }


    // RSA加密
    function setEncrypt (value) {
        var encrypt = new JSEncrypt();
        encrypt.setPublicKey(pubKey);
        return encrypt.encrypt(value);
    }

    // value为字符串，JS_RequestInterface仅接收json格式的变量，且需要先解析出argument，并且将argument字段的内容转为字符串
    function requestInterface(value)
    {
        isJSON(value);
        var JsonParam = JSON.parse(value);
        var JsonArgument = JsonParam.argument;
        JsonParam.argument = JSON.stringify(JsonArgument);
        console.log(value,'value11')
        oWebControl.JS_RequestInterface(JsonParam).then(function (oData) {
            // console.log(oData)
            // showCBInfo(JSON.stringify(oData ? oData.responseMsg : ''));
        });
    }

    // init
    function init(data) {
        console.log(data,'ja')
        var param = {
            "argument": {
                "appkey": "20708913",
                "ip": "192.168.100.1",
                "port": 443,
              "secret":"kg6rIAV3K2sSnDvOOo2Y",
                "enableHTTPS": 1,
                "language": "zh_CN",
                "layout": "2x2",
                "playMode": 0,
                "reconnectDuration": 5,
                "reconnectTimes": 5,
                "showSmart": 0,
                "showToolbar": 0,
                "toolBarButtonIDs": "",
                "snapDir": "D:/snap",
                "videoDir": "D:/video"
            },
            "funcName": "init"
        };
        //删除字符串中的回车换行和空格
		//param = param.replace(/(\s*)/g, "");
        //解析初始化时的playMode字段
        var initFuncType = 0;
        if (0 == initFuncType)
        {
            console.log(param,'````')
            isJSON(param);
            
            function checkType(val) {
                let type = Object.prototype.toString.call(val);
                if (type === "[object String]") {
                  return true
                }
              }
            var JsonParam = param;
            // JsonParam.argument = checkType(JsonParam.argument)?JSON.parse(JsonParam.argument):JsonParam.argument
            console.log(JsonParam,'JsonParam',checkType(JsonParam.argument))
            if (!JsonParam.hasOwnProperty("argument"))
            {
                // showCBInfo("init failed, param miss argument field");
            }
            else
            {
                if (JsonParam.argument.hasOwnProperty("playMode"))
                {
                    playMode = JsonParam.argument.playMode;
                }
                //隐藏/显示轮巡功能模块
                // document.getElementById("TourPreview").style.display= (0 == playMode && JsonParam.argument.hasOwnProperty("appkey")) ? "" : "none";
				
				//如果包含加密处理，处理加密字段
				if(JsonParam.argument.hasOwnProperty("encryptedFields"))
				{
				    var enFields = JsonParam.argument.encryptedFields;
					var strArray = new Array();
					strArray = enFields.split(",");
					for(var i = 0, len = strArray.length; i< len; i++)
					{
					    if("appkey" == strArray[i])
						{
							if (JsonParam.argument.hasOwnProperty("appkey"))
							{
								var appkey = JsonParam.argument.appkey;
								appkey = setEncrypt(appkey);
								JsonParam.argument.appkey = appkey;
							}
						}
						
						if("secret" == strArray[i])
						{
							if (JsonParam.argument.hasOwnProperty("secret"))
							{
								var secret = JsonParam.argument.secret;
								secret = setEncrypt(secret);
								JsonParam.argument.secret = secret;
							}
						}
						
						if("ip" == strArray[i])
						{
						    if (JsonParam.argument.hasOwnProperty("ip"))
							{
								var ip = JsonParam.argument.ip;
								ip = setEncrypt(ip);
								JsonParam.argument.ip = ip;
							}
						}
						
						if("snapDir" == strArray[i])
						{
						    if (JsonParam.argument.hasOwnProperty("snapDir"))
							{
								var snapDir = JsonParam.argument.snapDir;
								snapDir = setEncrypt(snapDir);
								JsonParam.argument.snapDir = snapDir;
							}
						}
						
						if("layout" == strArray[i])
						{
						    if (JsonParam.argument.hasOwnProperty("layout"))
							{
								var layout = JsonParam.argument.layout;
								layout = setEncrypt(layout);
								JsonParam.argument.layout = layout;
							}
						}
						
						if("videoDir" == strArray[i])
						{
						    if (JsonParam.argument.hasOwnProperty("videoDir"))
							{
								var videoDir = JsonParam.argument.videoDir;
								videoDir = setEncrypt(videoDir);
								JsonParam.argument.videoDir = videoDir;
							}
						}
					}
				}

                //1.4.1及以上版本支持argument字段为json，以下版本argument必须为string
                var JsonArgument = JsonParam.argument;
                JsonParam.argument = JSON.stringify(JsonArgument);
            }
            
            //param = {
            //    "argument": '{"appkey": "21216099","ip": "172.7.13.242","port": 443,"secret": "dX5Gt0C0hmKbQ9ucHnWY","enableHTTPS": 1,"language": "zh_CN","layout": "2x2","playMode": 0,"reconnectDuration": 5,"reconnectTimes": 5,"showSmart": 0,"showToolbar": 1,"snapDir": "D:/snap","videoDir": "D:/video"}',
            //    "funcName": "init"
            //}
            
            oWebControl.JS_RequestInterface(JsonParam).then(function (oData) {
                // console.log(oData)
                // showCBInfo(JSON.stringify(oData ? oData.responseMsg : ''));
                console.log(param,'param',oData,data)
                UpdatePlayParamValue(data);
                oWebControl.JS_Resize(getWndInfo().width, getWndInfo().height); //
            });
        }
        else{
            requestInterface(param);
        }

    //    setTimeout(()=>{
    //     requestInterface(param)
    //    },3000) 
    }
    
    // 设置布局/获取布局
    $("#layoutBtn").click(function() {
        var param = $("#layoutParam").val();
        //删除字符串中的回车换行
		//param = param.replace(/(\s*)/g, "");

        requestInterface(param);
    })
    
    //画面字符叠加
	$("#drawOSDBtn").click(function (){
        var param = $("#drawOSDParam").val();
        //删除字符串中的回车换行
		//param = param.replace(/(\s*)/g, "");

        requestInterface(param);
	})

    // 进入全屏
	$("#enterFullScreen").click(function (){
        oWebControl.JS_RequestInterface({
            funcName: "setFullScreen"
        }).then(function (oData) {
            console.log(oData)
            // showCBInfo(JSON.stringify(oData ? oData.responseMsg : ''));
        });
	})
    
    // 退出全屏
	$("#exitFullScreen").click(function (){
        oWebControl.JS_RequestInterface({
            funcName: "exitFullScreen"
        }).then(function (oData) {
            console.log(oData)
            // showCBInfo(JSON.stringify(oData ? oData.responseMsg : ''));
        });
	})
    
    //抓图
	$("#snapBtn").click(function (){
        var param = $("#snapParam").val();
        //删除字符串中的回车换行
		//param = param.replace(/(\s*)/g, "");

        requestInterface(param);
	})
    
    var timeStart = false;
    var timer;
    //轮巡，每隔10s执行一次
	$("#startTourPreviewBtn").click(function (){
        
        if (!timeStart)
        {
            timeStart = true;
            var sel = document.getElementById("tourPreviewType");
            var selectedId = sel.selectedIndex;
            var v = sel.options[selectedId].value;
            if (0 == v)     // 单路播放轮巡
            {
                SingleTourPreview();
                timer = window.setInterval(SingleTourPreview, 1000*10);
            }
            else{           // 批量播放轮巡
                MultiTourPreview();
                timer = window.setInterval(MultiTourPreview, 1000*10);
            }
        }
        else{
            // showCBInfo('start tour preview failed, please stop tour preview first');
        }
	})
    
    $("#stopTourPreviewBtn").click(function(){
        window.clearInterval(timer);
        timeStart = false;
    })
    
    // 单路播放轮巡函数
    function SingleTourPreview() {
        // 解析轮巡的监控点编号
        var param = $("#TourPreviewCamIdx").val();
        //param = param.replace(/(\s*)/g, "");
        var cameraIndexArray = new Array();
        cameraIndexArray = param.split(",");
        var arraySize = cameraIndexArray.length;
        
        // 获取当前窗口个数
        var WndNum = 1;
        oWebControl.JS_RequestInterface({
            funcName: "getLayout"
        }).then(function (oData) {
            //分析窗口数
            var Data = JSON.stringify(oData.responseMsg.data);
            Data = Data.replace(/\\n/g, "");
            Data = Data.replace(/\\/g, "");
            Data = Data.replace(/\"{/g, "{");
            Data = Data.replace(/}\"/g, "}");
            WndNum = JSON.parse(Data).wndNum;
            
            for (i = 0; i < WndNum; i++)
            {
                var cameraIdx = cameraIndexArray[i % arraySize];
                var previewParam = JSON.stringify({
                    "argument": {
                        "authUuid": "",
                        "cameraIndexCode": cameraIdx,
                        "ezvizDirect": 0,
                        "gpuMode": 0,
                        "streamMode": 0,
                        "transMode": 1,
                        "wndId": i+1,
		                "cascade": 1
                    },
                    "funcName": "startPreview"
                });
                requestInterface(previewParam);
            }
        });
    }
    
    // 批量播放轮巡函数
    function MultiTourPreview() {
        // 解析轮巡的监控点编号
        var param = $("#TourPreviewCamIdx").val();
        //param = param.replace(/(\s*)/g, "");
        var cameraIndexArray = new Array();
        cameraIndexArray = param.split(",");
        var arraySize = cameraIndexArray.length;
        
        // 获取当前窗口个数
        var WndNum = 1;
        oWebControl.JS_RequestInterface({
            funcName: "getLayout"
        }).then(function (oData) {
            //分析窗口数
            var Data = JSON.stringify(oData.responseMsg.data);
            Data = Data.replace(/\\n/g, "");
            Data = Data.replace(/\\/g, "");
            Data = Data.replace(/\"{/g, "{");
            Data = Data.replace(/}\"/g, "}");
            WndNum = JSON.parse(Data).wndNum;
            
            var multiPlayParam = {
                "argument": {
                    "list": []
                },
                "funcName": "startMultiPreviewByCameraIndexCode"
            }
            
            for (i = 0; i < WndNum; i++)
            {
                var PlayParam = {
                    "authUuid": "",
                    "cameraIndexCode": cameraIndexArray[i % arraySize],
                    "ezvizDirect": 0,
                    "gpuMode": 0,
                    "streamMode": 0,
                    "transMode": 1,
                    "wndId": i+1
                }

                multiPlayParam.argument.list.push(PlayParam);
            }
            var previewParam = JSON.stringify(multiPlayParam);
            requestInterface(previewParam);
        });
    }
    
    
    // 判断字符串是否为json
    function isJSON(str) {
        if (typeof str == 'string') {
            try {
                var obj=JSON.parse(str);
                if(typeof obj == 'object' && obj ){
                    return true;
                }else{
                    // showCBInfo("param is not the correct JSON message");
                    return false;
                }
            } catch(e) {
                // showCBInfo("param is not the correct JSON message");
                return false;
            }
        }
        console.log('It is not a string!')
    }

    // 格式化时间
    function dateFormat(oDate, fmt) {
        var o = {
            "M+": oDate.getMonth() + 1, //月份
            "d+": oDate.getDate(), //日
            "h+": oDate.getHours(), //小时
            "m+": oDate.getMinutes(), //分
            "s+": oDate.getSeconds(), //秒
            "q+": Math.floor((oDate.getMonth() + 3) / 3), //季度
            "S": oDate.getMilliseconds()//毫秒
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            }
        }
        return fmt;
    }

	function textbox(obj, min, max){
		obj.value=obj.value.replace(/[^\d]/g,'');
		if(parseInt(obj.value)==obj.value && parseInt(obj.value)>=min && parseInt(obj.value)<=max)
		{}
		else
		{
			if(parseInt(obj.value) < min)
			{
				obj.value = min;
			}
			if(parseInt(obj.value) > max)
			{
				obj.value = max;
			}
		}	
	}


    export default {
        initPlugin,
        init,
        undataHtml,
        openDataHtml,
    }
